package test;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import com.tycredit.demo.CreditApplication;

public class test {
    public static void main(String[] args) {
        Map bodyMap = new HashMap();
        bodyMap.put("originalTransKey", "SDGr4234gG465356gGT44");
        bodyMap.put("originalGenTime", "20171031124520");
        bodyMap.put("validPeriod", "0");
        bodyMap.put("keyType", "0");
        String privateKey = CreditApplication.privateKeyInvoke(
                "https://apitest.tycredit.com/credit-front-http/credit/apply-for-private-key.json",
                1,//测试标识testFlag,测试环境传1或5，生产环境传0
                "tianjudihe001", // 机构代码1
                getRandom(), // 发起方交易流水号32位不重复
                "10151112140001000001542155961605", // 授权号(符合字段要求即可)
                bodyMap,
                "8b7a547e0eb84b7e" // 天翼征信提供的home_key
        );
        System.out.println(privateKey);
    }

    /**
     * 返回 32 位 UUID
     * @return String UUID
     */
    public static String getRandom() {
        UUID uuid = UUID.randomUUID();
        return uuid.toString().replace("-", "");
    }

    public static String cardVerify() {
        Map bodyMap = new HashMap();
        bodyMap.put("originalTransKey", "SDGr4234gG465356gGT44");
        bodyMap.put("originalGenTime", "20171031124520");
        bodyMap.put("validPeriod", "0");
        bodyMap.put("keyType", "0");
        String privateKey = CreditApplication.privateKeyInvoke(
                "https://apitest.tycredit.com/credit-front-http/unified/threeElementsCheckSim.json",
                1,//测试标识testFlag,测试环境传1或5，生产环境传0
                "tianjudihe001", // 机构代码
                getRandom(), // 发起方交易流水号32位不重复
                "10151112140001000001542155961605", // 授权号(符合字段要求即可)
                bodyMap,
                "8b7a547e0eb84b7e" // 天翼征信提供的home_key
        );
        return privateKey;
    }
}
